export default {
	data() {
		return {
			//设置默认的分享参数
			sharedata: {
				title: '汇彩惠品', //分享标题
				path: '/pages/index/index',  //路径
				path: '',  //路径
				imageUrl: '',//分享图标，
				desc: '',  //自定义分享描述
				content: ''
			}
		}
	},
	//发送给朋友
	onShareAppMessage(res) {
		if(this.$all.getData('user')){
			this.sharedata.path='/pages/index/index?pid='+this.$all.getData('user').id
		}
		console.log(this.sharedata.path);
		return {
			title: this.sharedata.title,
			path: this.sharedata.path,
			imageUrl: this.sharedata.imageUrl,
			desc: this.sharedata.desc,
			content: this.sharedata.content,
			success(res) {
				uni.showToast({
					title: '分享成功'
				})
			},
			fail(res) {
				uni.showToast({
					title: '分享失败',
					icon: 'none'
				})
			}
		}
	},

	//uniapp微信小程序分享页面到微信朋友圈
	onShareTimeline(res) {
		if(this.$all.getData('user')){
			this.sharedata.path='/pages/index/index?pid='+this.$all.getData('user').id
		}
		console.log(this.sharedata.path);
		console.log(res);
		return {
			title: this.sharedata.title,
			query: '?pid='+this.$all.getData('user').id,
			imageUrl: this.sharedata.imageurl,
			success(res) {
				uni.showToast({
					title: '分享成功'
				})
			},
			fail(res) {
				uni.showToast({
					title: '分享失败',
					icon: 'none'
				})
			}
		}
	}

}

